<?php
namespace app\admin\controller\user;

use app\common\controller\AdminController;
use think\App;

/**
 * Class Topic
 * @package app\admin\controller\user
 * 会员动态
 */
class Topic extends AdminController{

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->model = app('app\common\model\user\Topic');
        $this->order = 'status asc,create_time asc';
    }

    public function get_where($array = []){
        $arr = [];
        if(isset($array['title']) && !empty($array['title'])){
            $arr[] = ['title','like','%'.$array['title'].'%'];
        }
        return $arr;
    }

    public function get_with(){
        return 'user';
    }

    public function action(){

        $param= $this->request->param();

        try{
            $row = $this->model->where('id',$param['id'])->find();
            $row->save($param);

        }catch (\Exception $exception){
            return json(['code'=>1,'msg'=>$exception->getMessage()]);
        }
        return json(['code'=>0,'msg'=>'操作成功']);
    }
}